package leetcode;

public class NumberComplement {

	public static void main(String[] args) {
		int i = -5;
		int count = 32;
		while( i != 0 && count >= 0){
			System.out.println(" " + i);
			i >>>= 1;
			count--;
		}
		System.out.println(1 << 0);
	}
	
    public int findComplement(int num) {
        if(num == 0){
            return 1;
        }
        int res = 0;
        int i = 0;
        while(num != 0){
            res = ((1 << i) ^ ((num & 1) << i)) + res;
            i++;
            num >>>= 1;
        }
        return res;
    }
}
